@namespace FluentCMS.Web.Plugins.Admin.FileManagement

<Modal Placement="ModalPlacement.Top" Visible Size="ModalSize.Large" OnClose="HandleCancel">
    <ModalHeader>
        <ModalTitle>
            Choose Folder
        </ModalTitle>
    </ModalHeader>
    <div style="max-height: 60vh; overflow: auto;">
            <Breadcrumb style="height: 40px; padding-left: 24px;">
            @foreach (var breadcrumbItem in ParentFolders)
            {
                @if (breadcrumbItem.Id == Model)
                {
                    <BreadcrumbItem>
                        @breadcrumbItem.Name
                    </BreadcrumbItem>
                }
                else if(breadcrumbItem.Id == RootFolder?.Id)
                {
                    <BreadcrumbItem Link @onclick="() => NavigateFolder(breadcrumbItem.Id)" IconName="IconName.Folder">
                        @breadcrumbItem.Name
                    </BreadcrumbItem>
                }
                else
                {
                    <BreadcrumbItem Link @onclick="() => NavigateFolder(breadcrumbItem.Id)">
                        @breadcrumbItem.Name
                    </BreadcrumbItem>
                }
            }
        </Breadcrumb>
        <FilesTable @key="@Model" HideFiles DisabledFolder="@DisabledFolder" @bind-FolderId="@Model" @bind-RootFolder="@RootFolder" @bind-ParentFolders="ParentFolders">
            <ActionsFragment>
                <ActionButtonOpen Visible="context.IsFolder && context.Id != DisabledFolder" @onclick="() => NavigateFolder(context.Id)" />
            </ActionsFragment>
        </FilesTable>
    </div>
    <ModalBody>
        <Grid>
            <GridItem Small="GridItemColumn.Twelve">
                <Stack>
                    <Button Color="@Color.Primary" @onclick="OnChooseFolder">Move Here</Button>
                    <Button @onclick="HandleCancel">Cancel</Button>
                </Stack>
            </GridItem>
        </Grid>
    </ModalBody>
</Modal>